<script setup>
import { ref, computed } from 'vue'
import { useStore } from '../../../store/useStore';
const store = useStore()
//子传父
const emit = defineEmits(['updates', 'updateForm'])
const getTop = () => {
    emit('updates')
}
//父传子
const prop = defineProps({
    forms: {
        default: true
    }
})
const localNclkName = ref(prop.forms.nclkName || '')
const isNameChange = computed(() => localNclkName.value !== prop.forms.nclkName)
const updateForms = (id, nickname) => {
    emit('updateForm', { id, nickname })
}

</script>
<template>
    <div class="appu" style="width: 100%;height: 100%;">
        <div class="topNav">
            <van-icon name="arrow-left" @click="getTop" />
            <span style="font-weight: bold;">更改名字</span>
            <button :style="{
                width: '50px',
                height: '30px',
                border: '0',
                fontSize: '15px',
                backgroundColor: isNameChange ? '#42b983' : '#dfdbdb',
                color: '#ffffff',
                borderRadius: '5px',
            }" @click="updateForms(store.info.id, store.info.nickname)">保存</button>
        </div>
        <div class="xias">
            <div class="xias_y">
                <input type="text" v-model="store.info.nickname">
            </div>
            <p class="ou_o">
                好名字可以让你的朋友更容易记住你
            </p>
        </div>
    </div>
</template>
<style scoped>
.xias {
    height: 100px;
    padding: 0 10px 0 10px;
}

.xias_y {
    height: 70px;
    border-bottom: 1px solid #d3d2d2;
    line-height: 100px;

    input {
        height: 50%;
        width: 100%;
        border: 0;
        background-color: #ebe9e9;
    }
}

.ou_o {
    height: 30px;
    line-height: 30px;
    color: #b3b1b1;
    font-size: 12px;
}

.topNav {
    display: flex;
    width: 100%;
    height: 50px;
    padding: 0 10px 0 10px;
    justify-content: space-between;
    align-items: center;
}

.appu {
    height: 100%;
    width: 100%;
    padding: 0 10px 0 10px;
    background-color: #ebe9e9;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 2009;
}
</style>